<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report:untransportwarning:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="untransportwarningList"
              @selection-change="handleSelectionChange">
      <el-table-column prop="id" label="序号" type="index">
        <template slot-scope="scope">
          <span>{{(queryParams.current - 1) * queryParams.size + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="项目名称" align="center" prop="projectName"/>
      <el-table-column label="清运公司" align="center" prop="transportCompany" width="280"/>
      <el-table-column label="清运时间" align="center" prop="bookingTime"/>
      <el-table-column label="是否超时" align="center" prop="overtime"/>
      <el-table-column label="超时时间(小时)" align="center" prop="times"/>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {listUntransportwarning} from "@/api/report/untransportwarning";

export default {
  name: "Untransportwarning",
  dicts: ['product_type', 'car_type_id', 'booking_state'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 未清运预警表格数据
      untransportwarningList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 修改时间时间范围
      daterangeBookingTime: [],
      // 查询参数
      queryParams: {
        current: 1,
        size: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询未清运预警列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeBookingTime && '' != this.daterangeBookingTime) {
        this.queryParams.params["beginBookingTime"] = this.daterangeBookingTime[0];
        this.queryParams.params["endBookingTime"] = this.daterangeBookingTime[1];
      }
      listUntransportwarning(this.queryParams).then(response => {
        this.untransportwarningList = response.records;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        projectId: null,
        bookingTime: null,
        completeTime: null,
        bookingCarNumber: null,
        carType: null,
        carTypeClassId: null,
        location: null,
        disposalLandId: null,
        transportCompanyId: null,
        state: null,
        createdDate: null,
        modifiedDate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeBookingTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('report/untransportwarning/export', {
        ...this.queryParams
      }, `untransportwarning_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
